package cn.edu.xmu.oomall.coupon.microservice;

import cn.edu.xmu.oomall.core.model.PageVo;
import cn.edu.xmu.oomall.coupon.microservice.vo.OnsaleRetVo;
import cn.edu.xmu.oomall.coupon.microservice.vo.ProductDetailVo;
import cn.edu.xmu.oomall.coupon.microservice.vo.ProductRetVo;
import cn.edu.xmu.oomall.coupon.microservice.vo.SimpleOnSaleInfoVo;
import cn.edu.xmu.privilegegateway.annotation.util.InternalReturnObject;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.ZonedDateTime;


/**
 * @author qingguo Hu 22920192204208
 */
@FeignClient(name = "goods-service")
public interface GoodsService {

    @ApiOperation(value = "通过Id返回OnsaleVo")
    @GetMapping("/internal/onsales/{id}")
    InternalReturnObject<OnsaleRetVo> getOnsaleById(@PathVariable("id") Long id);

    @ApiOperation(value = "通过productId查OnsaleVo（1对多）")
    @GetMapping("/internal/onsales")
    InternalReturnObject<PageInfo<SimpleOnSaleInfoVo>> listOnsale(@RequestParam(required = false) Long shopId,
                                                                  @RequestParam(required = false) Long productId,
                                                                  @RequestParam(value = "beginTime",required = false) @DateTimeFormat(pattern="uuuu-MM-dd'T'HH:mm:ss.SSSXXX") ZonedDateTime beginTime,
                                                                  @RequestParam(value = "endTime",required = false) @DateTimeFormat(pattern="uuuu-MM-dd'T'HH:mm:ss.SSSXXX") ZonedDateTime endTime,
                                                                  @RequestParam(value = "page",required = false,defaultValue = "1") Integer page,
                                                                  @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize);

    @GetMapping("/products/{id}")
    InternalReturnObject<ProductRetVo> getProductById(@PathVariable("id")Long id);

    @GetMapping("/internal/products/{id}")
    InternalReturnObject<ProductDetailVo> getProductByIdt(@PathVariable("id")Long id);
}

